package com.cardone.platform.common.service;

import java.util.List;

import lombok.Getter;
import lombok.Setter;

import com.cardone.common.dto.PaginationDto;
import com.cardone.context.ContextHolder;
import com.cardone.platform.common.dao.EntityTreeDao;
import com.cardone.platform.common.dto.EntityTreeDto;

/**
 * 实体树服务
 *
 * @author yaohaitao
 *
 */
@Getter
@Setter
public class EntityTreeDefaultService implements EntityTreeService {
	@Override
	public int deleteByIds(final EntityTreeDto deleteEntityTree) {
		return ContextHolder.getBean(EntityTreeDao.class).deleteByIds(deleteEntityTree);
	}

	@Override
	public <P> P findByCodeOrId(final Class<P> mappedClass, final EntityTreeDto findEntityTree) {
		return ContextHolder.getBean(EntityTreeDao.class).findByCodeOrId(mappedClass, findEntityTree);
	}

	@Override
	public <P> P findById(final Class<P> mappedClass, final EntityTreeDto findEntityTree) {
		return ContextHolder.getBean(EntityTreeDao.class).findById(mappedClass, findEntityTree);
	}

	@Override
	public <P> List<P> findListByLikeCode(final Class<P> mappedClass, final EntityTreeDto findListEntityTree) {
		return ContextHolder.getBean(EntityTreeDao.class).findListByLikeCode(mappedClass, findListEntityTree);
	}

	@Override
	public int insertByCode(final EntityTreeDto insertEntityTree) {
		return ContextHolder.getBean(EntityTreeDao.class).insertByCode(insertEntityTree);
	}

	@Override
	public <P> PaginationDto<P> paginationByLikeCode(final Class<P> mappedClass, final EntityTreeDto paginationEntityTree) {
		return ContextHolder.getBean(EntityTreeDao.class).paginationByLikeCode(mappedClass, paginationEntityTree);
	}

	@Override
	public Integer readByCodeNqIdForCount(final EntityTreeDto readEntityTree) {
		return ContextHolder.getBean(EntityTreeDao.class).readByCodeNqIdForCount(readEntityTree);
	}

	@Override
	public <P> P saveByIdOrCode(final Class<P> mappedClass, final EntityTreeDto saveEntityTree) {
		return ContextHolder.getBean(EntityTreeDao.class).saveByIdOrCode(mappedClass, saveEntityTree);
	}

	@Override
	public int updateByCode(final EntityTreeDto updateEntityTree) {
		return ContextHolder.getBean(EntityTreeDao.class).updateByCode(updateEntityTree);
	}
}